package com.api.main;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;


public class testMd5 {

	public static void main(String[] args) {
		//{"phone":"15666777688","smsflag":"01","imagecode":"1111","method":"checkImageVerification",
		//"timestamp":"2017-04-27 16:21:54","deviceid":"865479022050306","sign":"21177FBCB6972B47A0955A8147BF1CFC"}
		String p[]={"deviceid","timestamp","method","smsflag","phone","15666777688","01","1111","checkImageVerification","2017-04-27 16:21:54","865479022050306"};
		String pam="";
		for(int i=0;i<11;i++){
			pam=pam+""+p[i];
			for(int j=0;j<11;j++){
				if(j!=i){
				pam=pam+""+p[j];
						for(int k=0;k<11;k++){
							if(k!=i&&k!=j){
								pam=pam+""+p[k];
									for(int l=0;l<11;l++){
										if(l!=i&&l!=j&&l!=k){
											pam=pam+""+p[l];
											for(int m=0;m<11;m++){
												if(m!=i&&m!=j&&m!=k&&m!=l){
													pam=pam+""+p[m];
														for(int n=0;n<11;n++){
															if(n!=i&&n!=j&&n!=k&&n!=l&&n!=m){
																pam=pam+""+p[n];
																if((getMd5(pam)).startsWith("21")){
																System.out.println("=="+pam+"=="+getMd5(pam));
																}
																pam="";
																//break;
															}
														}
														//break;
												}
											}
											//break;
										}
									}
									//break;
							}
							
						}
						//break;
				}
			}
		}
		
	}
	
	 //静态方法，便于作为工具类  
    public static String getMd5(String plainText) {  
        try {  
            MessageDigest md = MessageDigest.getInstance("MD5");  
            md.update(plainText.getBytes());  
            byte b[] = md.digest();  
  
            int i;  
  
            StringBuffer buf = new StringBuffer("");  
            for (int offset = 0; offset < b.length; offset++) {  
                i = b[offset];  
                if (i < 0)  
                    i += 256;  
                if (i < 16)  
                    buf.append("0");  
                buf.append(Integer.toHexString(i));  
            }  
            //32位加密  
            return buf.toString();  
            // 16位的加密  
            //return buf.toString().substring(8, 24);  
        } catch (NoSuchAlgorithmException e) {  
            e.printStackTrace();  
            return null;  
        }  
  
    }  

}
